package com.leadbank.example.controller;

import com.leadbank.example.client.UserFeignClient;
import com.leadbank.example.domain.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by hp on 2019/4/24.
 */
@RequestMapping("/movies")
@RestController
@Slf4j
public class MovieController {

    @Autowired
    private UserFeignClient userFeignClient;

    @GetMapping("/users/{id}")
    public User findByid(@PathVariable Long id) {
        long begin = System.currentTimeMillis();

        User user = userFeignClient.findById(id);

        // ...电影微服务的业务...
        long end = System.currentTimeMillis();
        // 记录访问用时：
        log.info("访问用时：{}", end - begin);
        return user;
    }
}
